/** 
 * CSE 504: Compiler Design
 * Programming Assignment #3
 * Symbol Table
 *
 * By 
 *  Amitha Cheluvagopal
 *  ID# 107569253
 *  Email: amitha_c@yahoo.com
 *
 *  Naresh P Singh
 *  ID# 107669049
 *  Email: mail2naresh@gmail.com
 **/


class EntityBlock {
    NameBlock name;
    EntityKind kind;
    int nestingLevel;
    EntityBlock sameName;
    EntityBlock sameScope;
    MethodInfo  methodInfo;
    VariableInfo    varInfo;
    ClassInfo   classInfo;
    
    public EntityBlock() {
        super();
        this.name   = null;
        this.kind   = null;
        this.nestingLevel   = 0;
        this.sameName   = null;
        this.sameScope  = null;
        this.methodInfo     = null;
        this.varInfo        = null;
        this.classInfo      = null;
    }
    
    public EntityBlock(NameBlock name, EntityKind kind, int nestingLevel) {
        super();
        this.name   = name;
        this.kind   = kind;
        this.nestingLevel   = nestingLevel;
        this.sameName   = null;
        this.sameScope  = null;
        this.methodInfo     = null;
        this.varInfo        = null;
        this.classInfo      = null;

    }

    public NameBlock getName() {
        return name;
    }

    public void setName(NameBlock name) {
        this.name = name;
    }

    public EntityKind getKind() {
        return kind;
    }

    public void setKind(EntityKind kind) {
        this.kind = kind;
    }

    public int getNestingLevel() {
        return this.nestingLevel;
    }

    public void setNestingLevel(int nestingLevel) {
        this.nestingLevel = nestingLevel;
    }

    public EntityBlock getSameName() {
        return sameName;
    }

    public void setSameName(EntityBlock sameName) {
        this.sameName = sameName;
    }

    public EntityBlock getSameScope() {
        return this.sameScope;
    }

    public void setSameScope(EntityBlock sameScope) {
        this.sameScope = sameScope;
    }

    public VariableInfo getVarInfo() {
        return this.varInfo;
    }
    
    public MethodInfo getMethodInfo() {
        return this.methodInfo;
    }
    
    public ClassInfo getClassInfo() {
        return this.classInfo;
    }

    public void setInfo(MethodInfo methodInfo) {
        this.methodInfo = methodInfo;
    }

    public void setInfo(ClassInfo classInfo) {
        this.classInfo  = classInfo;
    }

    public void setInfo(VariableInfo varInfo) {
        this.varInfo    = varInfo;
    }

	public void printInsert() {
        System.out.println("Insert Entry in Symbol Table: " + this.getName().getId() + " " + EntityKind.getKindStr(this.getKind()) + " Nesting_level(" + this.getNestingLevel() + ")");
	}

	public void printLookupCurScope() {
		System.out.println(this.getName().getId() + " with the type " + EntityKind.getKindStr(this.getKind()) + " exists and is in current scope");
	}

	public void printLookupPrevScope() {
		System.out.println(this.getName().getId() + " with the type " + EntityKind.getKindStr(this.getKind()) + " exists and is in other scope");
	}

   public String getPrintMsg() {
      String retStr  = "(Entry in Symbol Table: " + this.getName().getId() + " " + EntityKind.getKindStr(this.getKind()) + " Nesting_Level(" + this.getNestingLevel() + "))";
      return retStr;
   }
}
